package data;

import java.net.UnknownHostException;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;
import com.mongodb.MongoOptions;

public class Datas {
	static Mongo m = null;

	public static DBCollection data(String name) {

		if (m == null) {
			try {
				MongoOptions options = new MongoOptions();
				options.connectionsPerHost = 10;
				options.autoConnectRetry = true;
//				List addrs = new ArrayList();
//				addrs.add(new ServerAddress("174.142.68.9", 27017));
//				addrs.add(new ServerAddress("72.55.164.55", 27017));
				m = new Mongo("222.255.28.33", options);

			} catch (UnknownHostException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (MongoException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		DB db = m.getDB("hat");

		DBCollection coll = db.getCollection(name);
		return coll;
	}
}
